/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sdd.plains;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author ceu
 */
public class ProductPlain implements Serializable {
    private Long productId;
    private Double price;
    private String description;
    private String name;
    
    private List<CategoryPlain> categories; //quitar..?
    private List<FeaturePlain> features;
    

    /**
     * @return the productId
     */
    public Long getProductId() {
        return productId;
    }

    /**
     * @param productId the productId to set
     */
    public void setProductId(Long productId) {
        this.productId = productId;
    }

    /**
     * @return the price
     */
    public Double getPrice() {
        return price;
    }

    /**
     * @param price the price to set
     */
    public void setPrice(Double price) {
        this.price = price;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "ProductPlain{" + "productId=" + productId + ", price=" + price + ", description=" + description + ", name=" + name + ", categories=" + categories + '}';
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof ProductPlain) {
            ProductPlain other = (ProductPlain) obj;
            return other.getProductId() == this.getProductId();
        }
        else if(obj instanceof CartItem) {
            CartItem other = (CartItem) obj;
            return other.getProduct().getProductId() == this.getProductId();
        }
        return false;
    }

    /**
     * @return the categories
     */
    public List<CategoryPlain> getCategories() {
        return categories;
    }

    /**
     * @param categories the categories to set
     */
    public void setCategories(List<CategoryPlain> categories) {
        this.categories = categories;
    }
    
    public void addCategory(CategoryPlain cp){
        if(categories==null){
            categories = new ArrayList<CategoryPlain>();
        }
        categories.add(cp);
    }

    /**
     * @return the features
     */
    public List<FeaturePlain> getFeatures() {
        return features;
    }

    /**
     * @param features the features to set
     */
    public void setFeatures(List<FeaturePlain> features) {
        this.features = features;
    }



}
